package com.cloudpivot.receivales.crm.repository.contract;

import com.cloudpivot.receivales.crm.entity.contract.ContractEntity;
import com.cloudpivot.receivales.crm.entity.weekly.WeeklyCount;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ContractCalRepository extends JpaRepository<ContractEntity, String> {

    /**
     * 获取组合后的crm 合同
     * @return
     */
    @Query(nativeQuery = true, value = "select maint.new_ccusname,maint.new_cdefine12,maint.new_cdefine13,maint.new_contract_name,maint.new_main_contractid,subt.new_sub_contractid,subt.new_cinvcode,subt.new_cinvname,subt.new_iquantity,subt.new_inatsum,subt.statecode as sub_statecode,maint.statecode as main_statecode from db.crm_new_main_contracts maint inner join db.crm_new_sub_contracts subt on subt._new_contract_value=maint.new_main_contractid where new_cdefine12 not in ('内部合同','内部备案')")
    List<ContractEntity> getNormalList();

    @Query(nativeQuery = true, value = "select maint.new_ccusname,maint.new_cdefine12,maint.new_cdefine13,maint.new_contract_name,maint.new_main_contractid,subt.new_sub_contractid,subt.new_cinvcode,subt.new_cinvname,subt.new_iquantity,subt.new_inatsum,subt.statecode as sub_statecode,maint.statecode as main_statecode from db.crm_new_main_contracts maint inner join db.crm_new_sub_contracts subt on subt._new_contract_value=maint.new_main_contractid where new_cdefine12 in ('内部合同','内部备案')")
    List<ContractEntity> getInnerList();
}
